package com.cy.demosharding;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.cy.demosharding.model.Order;
import com.cy.demosharding.service.OrderService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.math.BigDecimal;

@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@MapperScan("com.cy.demosharding.mapper")
public class DemoShardingApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext applicationContext = SpringApplication.run(DemoShardingApplication.class, args);
		OrderService orderService = applicationContext.getBean(OrderService.class);

		for (int i = 0; i < 4; i++) {
			Order order = new Order();
			order.setOrderNo("A000" + i);
			order.setCreateName("订单 " + i);
			order.setPrice(new BigDecimal("" + i));
			orderService.save(order);

		}
	}

}
